﻿package com.yy.ui.general {
    import com.yy.ui.core.UISprite;
    
    import flash.display.*;

    public class ScaleDisplayObject extends UISprite {

        private var offsetX:Number = 0;
        private var offsetY:Number = 0;
        private var child:Sprite;
        private var displayObject:DisplayObject;
        private var _width:Number = 0;
        private var _height:Number = 0;
        private var _scaleX:Number = 1;
        private var _scaleY:Number = 1;
        private var preX:Number = 0;
        private var preY:Number = 0;

        public function ScaleDisplayObject(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=0){
            this.offsetX = _arg2;
            this.offsetY = _arg3;
            this.displayObject = _arg1;
            this._width = _arg1.width;
            this._height = _arg1.height;
            this.child = new Sprite();
            _arg1.x = (-((this._width / 2)) + _arg2);
            _arg1.y = (-((this._height / 2)) + _arg3);
            this.child.addChild(_arg1);
            addChild(this.child);
            this.x = 0;
            this.y = 0;
        }
        override public function set width(_arg1:Number):void{
            this._width = _arg1;
            this.displayObject.width = _arg1;
            this.displayObject.x = (-((this._width / 2)) + this.offsetX);
            this.x = this.preX;
        }
        override public function get width():Number{
            return (this._width);
        }
        override public function set height(_arg1:Number):void{
            this._height = _arg1;
            this.displayObject.height = _arg1;
            this.displayObject.y = (-((this._height / 2)) + this.offsetY);
            this.y = this.preY;
        }
        override public function get height():Number{
            return (this._height);
        }
        override public function set scaleX(_arg1:Number):void{
            this._scaleX = _arg1;
            this.child.scaleX = _arg1;
        }
        override public function get scaleX():Number{
            return (this._scaleX);
        }
        override public function set scaleY(_arg1:Number):void{
            this._scaleY = _arg1;
            this.child.scaleY = _arg1;
        }
        override public function get scaleY():Number{
            return (this._scaleY);
        }
        override public function set x(_arg1:Number):void{
            this.preX = _arg1;
            super.x = (_arg1 + (this._width / 2));
        }
        override public function get x():Number{
            return ((super.x - (this._width / 2)));
        }
        override public function set y(_arg1:Number):void{
            this.preY = _arg1;
            super.y = (_arg1 + (this._height / 2));
        }
        override public function get y():Number{
            return ((super.y - (this._height / 2)));
        }

    }
}